var { ReturnModel } = require('../libs/resmodel');
var { activeList, activeListBack, activeQueryone, activeAdd, activeUpdate } = require('../services/active');

async function list(req, res) {
    let result = await activeList(req.body);
    res.json(new ReturnModel(result));
}
async function listback(req, res) {
    let result = await activeListBack(req.body);
    res.json(new ReturnModel(result));
}
async function queryone(req, res) {
    let result = await activeQueryone(req.body);
    res.json(new ReturnModel(result));
}
async function add(req, res) {
    let result = await activeAdd(req.body);
    res.json(new ReturnModel(result));
}
async function update(req, res) {
    let result = await activeUpdate(req.body);
    res.json(new ReturnModel(result));
}

module.exports = function (app) {
    let base_url = '/api/active';

    app.post(base_url+'/list', list);
    app.post(base_url+'/listback', listback);
    app.post(base_url+'/queryone', queryone);
    app.post(base_url+'/add', add);
    app.post(base_url+'/update', update);
}
